package ca.newcommerce.youtube.feeds
{
    import ca.newcommerce.youtube.data.*;
    import ca.newcommerce.youtube.iterators.*;
    import com.adobe.serialization.json.*;

    public class AbstractFeed extends AbstractData
    {
        protected var _feedPointer:Number = -1;
        protected var _data:Object;
        protected var _entries:Array;

        public function AbstractFeed(param1:String)
        {
            this._data = JSON.decode(param1).feed;
            this._entries = this._data.entry;
            return;
        }// end function

        public function get authors() : AuthorIterator
        {
            return new AuthorIterator(this._data.author);
        }// end function

        public function get updated() : String
        {
            return fromObj(this._data, "updated");
        }// end function

        public function get logo() : String
        {
            return fromObj(this._data, "logo");
        }// end function

        public function get itemsPerPage() : Number
        {
            return parseInt(fromObj(this._data, "openSearch$itemsPerPage"));
        }// end function

        public function get count() : Number
        {
            return this._entries != null ? (this._entries.length) : (0);
        }// end function

        public function get startIndex() : Number
        {
            return parseInt(fromObj(this._data, "openSearch$startIndex"));
        }// end function

        public function get totalResults() : Number
        {
            return parseInt(fromObj(this._data, "openSearch$totalResults"));
        }// end function

        public function get title() : String
        {
            return fromObj(this._data, "title");
        }// end function

        public function get links() : LinkIterator
        {
            return new LinkIterator(this._data.link);
        }// end function

        public function get generator() : GeneratorData
        {
            return new GeneratorData(this._data.generator);
        }// end function

        public function get id() : String
        {
            return fromObj(this._data, "id");
        }// end function

        public function get categories() : CategoryIterator
        {
            return new CategoryIterator(this._data.category);
        }// end function

    }
}
